package com.jsb.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jsb.model.Admin;
import com.jsb.model.User;

@Controller
public class OutSystem {


    /***
     *
     * 名称：OutSystem <br/>
     * 描述：用户退出 <br/>
     * 
     * @return
     */
    @SuppressWarnings("deprecation")
    @RequestMapping("/outSystem")
    public String outSystem(String page, HttpServletRequest request, HttpServletResponse response) {
    	Admin loginUser = (Admin) request.getSession().getAttribute("loginUser");
//        CiaWeblog ciaWeblog = null;
        if (null != loginUser) {
//            ciaWeblog = new CiaWeblog();
//            ciaWeblog.setId(PublicMethod.getUUID());
//            ciaWeblog.setType(Const.SYSTEM_EXIT);
//            ciaWeblog.setDate(new Date());
//            ciaWeblog.setDeveloperId(loginUser.getId());
//            ciaWeblog.setDescription("用户：" + loginUser.getAccount() + "在" + ciaWeblog.getDate().toLocaleString() + "退出系统！");
//            ciaWeblogExService.insertCiaWeblog(ciaWeblog);
        } else {
            return "/login";
        }
        HttpSession session = request.getSession(false);
        session.invalidate();
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        if (null != page && !"".equals("undefined") && (page.endsWith(".html") || page.endsWith(".jsp"))) {
            return "redirect:/" + page;
        }
//        return "redirect:/index.html";
         return "/login";
    }

}
